﻿using System;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Electrical;
using Autodesk.Revit.DB.Mechanical;
using Autodesk.Revit.DB.Plumbing;
using Autodesk.Revit.UI.Selection;

namespace HangerSupport
{
	public class PipeSelectionFilter : ISelectionFilter
	{
		public PipeSelectionFilter(bool bSelectOnlyHorPipe = true)
		{
			this.m_bSelectOnlyHorPipe = bSelectOnlyHorPipe;
		}

		public bool AllowElement(Element element)
		{
			bool flag = PipeSelectionFilter.IsPipeDuct(element);
			bool result;
			if (flag)
			{
				bool bSelectOnlyHorPipe = this.m_bSelectOnlyHorPipe;
				result = (!bSelectOnlyHorPipe || Utils.IsHorizontalPipe(element));
			}
			else
			{
				result = false;
			}
			return result;
		}

		public static bool IsPipeDuct(Element element)
		{
			return element is Pipe || element is Duct || element is CableTray || element is Conduit;
		}

		public bool AllowReference(Reference refer, XYZ point)
		{
			return false;
		}

		private bool m_bSelectOnlyHorPipe = true;
	}
}
